package edu.kit.csl.pisa.training;

/*
This file is part of the PISA Alignment Tool.

Copyright (C) 2013
Karlsruhe Institute of Technology
Cognitive Systems Lab (CSL)
Felix Stahlberg

PISA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

PISA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with PISA. If not, see <http://www.gnu.org/licenses/>.
*/

import edu.kit.csl.pisa.datatypes.SentencePair;
import edu.kit.csl.pisa.models.AlignmentModel;

/**
 * This class uses the design pattern strategy. Implementing subclasses offer
 * different strategies of how to find a (local/global) maximum giving the
 * model parameters, the source sentence, and the target language. Starting out
 * from a initial alignment, it gradually changes connections in order to
 * maximize P(a,f|e) given by the alignment model.
 */
abstract public class MaximizationStrategy {

	protected AlignmentModel model;
	
	/**
	 * Sole constructor.
	 * 
	 * @param model Alignment model. This may be used to get some parameters
	 * 		from the configuration
	 */
	public MaximizationStrategy(AlignmentModel model) {
		this.model = model;
	}
	
	/**
	 * Apply the maximization strategy. Find a local/global maximum starting
	 * out from the given start alignment.
	 * 
	 * @param pair the sentence alignment to maximize. The given alignment is used
	 * 				as starting point. The resulting alignment overrides this
	 * 				alignment after maximization
	 * @throws UnsupportedOperationException if the strategy is not implemented
	 */
	abstract public void maximize(SentencePair pair)
			throws UnsupportedOperationException;
}
